﻿/*
 *  This program is free software; you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation; either version 2 of the License, or
 *  (at your option) any later version.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with this program; if not, write to the Free Software
 *  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 */

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Daidalos.VFS
{
    /// <summary>
    /// 
    /// </summary>
    public enum FileMode
    {
        TEXT    = 0,
        BINARY  = 1,
        AUTO    = 2,
    }

    /// <summary>
    /// 
    /// </summary>
    public enum OpenMode
    {
        READ    = 0x01,
        WRITE   = 0x02,
        APPEND  = 0x04,
        HYBRID  = 0x03,
    }

    /// <summary>
    /// 
    /// </summary>
    public class Vfs : Patterns.SingletonManager<Vfs>
    {
        /// <summary>
        /// 
        /// </summary>
        /// <param name="name"></param>
        /// <returns></returns>
        public File OpenFile(string name)
        {
            return OpenFile(name, OpenMode.HYBRID, FileMode.AUTO);
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="name"></param>
        /// <param name="openmode"></param>
        /// <returns></returns>
        public File OpenFile(string name, OpenMode openmode)
        {
            return OpenFile(name, openmode, FileMode.AUTO);
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="name"></param>
        /// <param name="openmode"></param>
        /// <param name="filemode"></param>
        /// <returns></returns>
        public File OpenFile(string name, OpenMode openmode, FileMode filemode)
        {
            if (filemode == FileMode.TEXT)
            {
                return new TextFile(name, openmode);
            }
            else if (filemode == FileMode.BINARY)
            {
                return new BinaryFile(name, openmode);
            }
            return null;
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="name"></param>
        /// <returns></returns>
        public string ReadTextFile(string name)
        {
            TextFile file = (TextFile)OpenFile(name, OpenMode.READ);

            return null;
        }
    }
}
